//
//  PrizeClawVideoHandler.hpp
//  MyApp
//
//  Created by Don on 2017/8/22.
//
//

#ifndef PrizeClawVideoHandler_hpp
#define PrizeClawVideoHandler_hpp

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>

// 定义函数指针类型
typedef void (*FrameAvailableMessageHandler)(void *ref,uint8_t *);
typedef void (*FrameErrorMessageHandler)(void *ref,const int errorCode);

class PrizeClawVideoHandler
{
    
public:
    ~PrizeClawVideoHandler();
    static PrizeClawVideoHandler* getInstance();
    
    
    void starPrizeClawVideo(const char* rtmp_ip, const char* id, int channel, int width, int height);
    void setCameraChannel(int channel);
    
//    CGSize getVideoSize();
    
    // 注册 视频帧 回调的函数
    void registerFrameAvailableCallBackFunction(void *,FrameAvailableMessageHandler);
    void registerFrameErrorCallBackFunction(void *,FrameErrorMessageHandler);
    
private:
    PrizeClawVideoHandler();
    //把复制构造函数和=操作符也设为私有,防止被复制
    PrizeClawVideoHandler(const PrizeClawVideoHandler&);
    PrizeClawVideoHandler& operator=(const PrizeClawVideoHandler&);
    
    
    // 要实现这个回调的对象
    void *ref;
    // 函数声明
    FrameAvailableMessageHandler frameAvailableHandler;
    FrameErrorMessageHandler frameErrorHandler;
    
    static void notifyFrameAvailable();
    static void notifyError(int error);
    
    
    void toggleCamera(int channel);
    void closeVidel();
    void initRender();
    void initRenderFrame();
    
};

#ifdef __cplusplus
}
#endif

#endif /* PrizeClawVideoCallbackHandler_hpp */
